<%@ page import="com.zgroup.domain.Picture" %>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="layout" content="common_header"/>
  <g:set var="entityName" value="${message(code: 'picture.label', default: 'Picture')}"/>
  <title><g:message code="default.edit.label" args="[entityName]"/></title>
  <script type="javascript">
    function save(id) {
      //jQuery("#id").val(id)
      jQuery("#submitForm").ajaxSubmit({
        success: function(response) {
          if (response == "1") {
            alert("修改成功")
          } else {
            alert("修改出错")
          }
        }
      });
    }
  </script>
</head>
<body>
<div class="body">
  <h1><g:message code="default.edit.label" args="[entityName]"/></h1>
  <g:if test="${flash.message}">
    <div class="message">${flash.message}</div>
  </g:if>
  <g:hasErrors bean="${pictureInstance}">
    <div class="errors">
      <g:renderErrors bean="${pictureInstance}" as="list"/>
    </div>
  </g:hasErrors>
  <form id="submitForm" name="submitForm" action="${createLink(controller: "scaffold", action: 'save', absolute: true)}" method="post">
    <g:hiddenField name="id" value="${pictureInstance?.id}"/>
    <input type="hidden" name="property" value="picture"/>
    <input type="hidden" name="view" value="/picture/edit"/>
    <div class="dialog">
      <table>
        <tbody>

        <tr class="prop">
          <td valign="top" class="name" align="right">
            文件名：
          </td>
          <td><g:textField name="fileName" maxlength="100" value="${pictureInstance?.fileName}"/></td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name" align="right">
            <label for="dateCreated"><g:message code="picture.dateCreated.label" default="创建日期："/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: pictureInstance, field: 'dateCreated', 'errors')}">
            <g:datePicker name="dateCreated" precision="day" value="${pictureInstance?.dateCreated}"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name" align="right">
            <label for="type"><g:message code="picture.type.label" default="类型："/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: pictureInstance, field: 'type', 'errors')}">
            <g:textField name="type" maxlength="6" value="${pictureInstance?.type}"/>
          </td>
        </tr>

        <tr class="prop" style="display:none">
          <td valign="top" class="name">
            <label for="info"><g:message code="picture.info.label" default="Info"/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: pictureInstance, field: 'info', 'errors')}">
            <g:select name="info.id" from="${com.zgroup.domain.InfoRelease.list()}" optionKey="id" value="${pictureInstance?.info?.id}" noSelection="['null': '']"/>
          </td>
        </tr>

        <tr class="prop" style="display:none">
          <td valign="top" class="name">
            <label for="fromEstate"><g:message code="picture.fromEstate.label" default="From Estate"/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: pictureInstance, field: 'fromEstate', 'errors')}">
            <g:select name="fromEstate.id" from="${com.zgroup.domain.Estate.list()}" optionKey="id" value="${pictureInstance?.fromEstate?.id}" noSelection="['null': '']"/>
          </td>
        </tr>

        <tr class="prop">
          <td valign="top" class="name" align="right">
            <label for="desc"><g:message code="picture.desc.label" default="描述："/></label>
          </td>
          <td valign="top" class="value ${hasErrors(bean: pictureInstance, field: 'desc', 'errors')}">
            <g:textArea name="desc" value="${pictureInstance?.desc}"/>
          </td>
        </tr>
        </tbody>
      </table>
    </div>
    <div class="buttons">
      <span class="button"><input class="save" type="button" value="修改" onclick="save('${pictureInstance?.id}')"/></span>
      <span class="button"><g:actionSubmit class="delete" action="delete" value="删除" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');"/></span>
    </div>
  </form>
  <img src="${resource(dir: '/upload/info_picture/', file: pictureInstance?.fileName, absolute: true)}" width="400" height="300">
</div>
</body>
</html>
